<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
	<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
	<title>管理收货地址</title>
	<link rel="stylesheet" type="text/css" href="__CSS__/api.css" />
	<link rel="stylesheet" type="text/css" href="__CSS__/aui.css" />
	<style>
		body {
			background-color: #F4F4F4;
		}

		.title {
			font-size: 14px;
			color: #555555;
			padding-left: 0.75rem;
			height: 1.875rem;
			line-height: 1.875rem;
		}

		.addr {
			height: 3.85rem;
			width: 100%;
			background-color: #FFFFFF;
			padding-left: 0.775rem;
			padding-right: 0.525rem;
			padding-top: 0.75rem;
			padding-bottom: 0.75rem;
			font-size: 14px;
			color: #999999;
		}

		.edit {
			width: 0.85rem;
			height: 0.85rem;
			margin-top: 0.75rem;
		}

		.edit img {
			width: 100%;
			height: 100%;
		}

		.address {
			padding-top: 0.3rem;
			font-size: 14px;
			color: #555555;
		}

		.create {
			font-size: 15px;
			color: #FFFFFF;
			width: 100%;
			height: 2.55rem;
			line-height: 2.55rem;
			text-align: center;
			background: -webkit-linear-gradient(right, #F04040, #FF7A7A);
			position: fixed;
			left: 0;
			bottom: 0;
		}

		.name {
			padding-right: 1.3rem;
		}
	</style>
</head>

<body>
	<div class="title">我的收货地址</div>
	{if !$address}
     <div class="seat" id="seatAll">
     		<img src="__IMG__/quexing/no_content.png" class="seatImg"/>
    		<div class="seatName">没有符合条件的内容</div>
     </div>
	{/if}
<div id="list"></div>
{volist name='address' id='add'}
	<div class="addr" onclick="sure(this)" add_id='{$add.add_id}' add_lon='{$add.add_lon}' add_lat='{$add.add_lat}' add_address='{$add.add_address}'>
		<div class="flex-wrap">
			<div class="flex-con">
				<div class="flex-wrap">
					<div class="name">{$add.add_username}</div>
					<div class="flex-con">{$add.add_phone|substr=0,4}****{$add.add_phone|substr=7,4}</div>
				</div>
				<div class="address">{$add.add_address}</div>
			</div>
			<div class="edit">
				<img src="__IMG__/edit.png" />
			</div>
		</div>
	</div>
{/volist}
	<div class="create" onclick="add()" tapmode>新建收货地址</div>
</body>
<input type="hidden" id="type" value="{$type}" />
<script type="text/javascript" src="__JS__/jquery.min.js"></script>
<script type="text/javascript">
	function sure(el) {
	    var type = $('#type').val();
	    //----------------------
        var id = $(el).attr('add_id');
	    if(type == 1){
            var lon = $(el).attr('add_lon');
            var lat = $(el).attr('add_lat');
            var add = $(el).attr('add_address');
            $.ajax({
                url:'{:url("Index/indexGetData")}',
                data: 'lat='+lat+'&lon='+lon+'&address='+add+'&aid='+id,//
                type:'POST',
                dataType:'JSON',
                success: function(returndata){
                    location.href = '{:url("home/Index/index")}';
                },
                error:function () {
                    alert('Ajax error!');
                }
            })
		}else{
            location.href = '{:url("home/My/addAdd")}?addid='+id;//带此参为编辑
		}

    }
    function add() {
        var type = $('#type').val();
        if(type == 1){
            location.href = '{:url("home/Index/addAdd")}';
        }else{
            location.href = '{:url("home/My/addAdd")}';
        }
    }

    pushHistory();
    window.addEventListener("popstate", function(e) {
        var type = $('#type').val();
        if(type == 1){
            location.href = '{:url("home/Index/index")}';
		}else{
            location.href = '{:url("home/My/index")}';
		}

    }, false);
    function pushHistory() {
        var state = {
            title: "title",
            url: "#"
        };
        window.history.pushState(state, "title", "#");
    }
    XBack.listen(function(){
        alert('back');
    });
</script>

</html>
